import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;

import com.sun.net.httpserver.HttpExchange;

import com.sun.net.httpserver.HttpHandler;

import com.sun.net.httpserver.HttpServer;

public class SimpleHttpServer {

	public static void main(String[] args) throws Exception {

		HttpServer server = HttpServer.create(new InetSocketAddress(7070), 0);

		server.createContext("/wechat/receiver/wx7b9786318bf71dad", new MyHandler());

		server.setExecutor(null); // creates a default executor

		server.start();

	}

	static class MyHandler implements HttpHandler {

		public void handle(HttpExchange t) throws IOException {

			String response = "success";

			t.sendResponseHeaders(200, response.length());

			OutputStream os = t.getResponseBody();

			os.write(response.getBytes());
			os.flush();
			os.close();

		}

	}

}
